const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');

const resolve = (p) => path.resolve(__dirname, p);

function getSecret() {
  // 读取YAML文件内容
  const fileContents = fs.readFileSync(resolve('../config/secret.yml'), 'utf8');
  // 将YAML内容解析为JavaScript对象
  const config = yaml.load(fileContents);

  return config;
}

function getDatabase() {
  // 读取YAML文件内容
  const fileContents = fs.readFileSync(
    resolve('../config/database.yml'),
    'utf8',
  );
  // 将YAML内容解析为JavaScript对象
  const config = yaml.load(fileContents);

  return config;
}

module.exports = {
  getSecret,
  getDatabase,
};
